home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Applications / Siege Watch 2.0 Folder / Read Me -- Speech Daemon GH < prev    next >
Text File  |  1994-04-20  |  6KB  |  183 lines

  1. Speech Daemon GH v 1.0.2 by Glenn R. Howes 4/20/94
  2.     based on the sample daemon by C.K. Haun provided with Develop Issue#9
  3. =======================
  4.  
  5. Description:
  6.     Speech Daemon GH is a small background only application which is designed to
  7. give speech capability to programs, such as INIT's, control panels, apple scripts,
  8. and programs running on remote computers. It can be interface through either
  9. the Program to Program Communications Toolbox (PPC) or via the AppleEventâ„¢
  10. mechanism. I've written two separate programs, Speech Note GH 2.0 and Remote
  11. Speak GH 1.0, which make use of these abilities.
  12.  
  13.     If you make frequent use of the Daemon, it is most convenient to put an alias to
  14. it into your StartUp Items folder (which is in your System Folder).
  15.  
  16. ======================
  17.  
  18. Requirements:
  19.     System 7, the Speech Manager. The Daemon will run happily in a 50k partition,
  20. however, to use the Macintalk Pro voices a partition of 220 to 300k is required.
  21. If there isn't enough room, the daemon will use the system voice (Marvin?).
  22.      It is highly recommended that you install Sound Manager 3.0, as it will
  23. minimize interference with system beeps and other sounds.
  24.  
  25. ** It appears as if the daemon is incompatible with Star Trek the 25th aniversary
  26. ** game. I'm not placing blame and I'm looking for a solution. 
  27.  
  28. ** When running, there will be no icon for Speech Daemon GH displayed under
  29. ** the application menu.
  30.  
  31. ** Just because the Daemon's icon is dimmed does not mean it is currently 
  32. ** running--although if it is undimmed, the Daemon is definitely not running.
  33. ** This is a Finder bug. You can do a Get Info on the Daemon's icon
  34. ** and if you can change the partition size, the daemon is not running.
  35.  
  36. ** Holding the shift key down just after the desktop appears during startup will
  37. ** prevent the items in the startup items folder from launching.
  38.  
  39.  
  40. =======================
  41. Limitations:
  42.     The Daemon can only speak one string at a time and have one string pending. It can
  43.     only speak chunks 255 characters or less. It can only process one string at a time
  44.     from AppleScript with nothing pending. If you want a more elaborately scriptable 
  45.     Daemon, I would suggest SpokesDaemon by Eric Weidl; I'm sure he would appreciate
  46.     the shareware fee.
  47.  
  48. ====================
  49. AppleScripting:
  50.   The daemon has an 'aete' resource, so you can just use Apple's Script Editor to get
  51. a list of the commands the daemon supports.
  52.  
  53. ====================
  54. Programming:
  55.  
  56.     If you as a programmer want to interface with this daemon from your own code
  57. using PPC calls, you will need to examine the following sample code for a synchronous
  58. call to the daemon:
  59.  
  60. /* Most of this was taken from sample code provided on the Develop CD under the
  61. ** title "Sample Control Panel Device and INIT Combination"
  62. **/
  63. #define    kDaemonVersion 1
  64. typedef struct MyVoiceInfo
  65. {
  66.     short            version;
  67.     Fixed            volume;
  68.     Fixed            rate;
  69.     Fixed            modulation;
  70.     Fixed            pitch;
  71.     VoiceSpec        theVoice;
  72.     Str255            string2Speak;
  73.     Boolean            keepVoice;
  74.     unsigned long    waitTime;  // time in ticks which the daemon should delay before speaking
  75.     unsigned long    ticks; // system tick count when the daemon was called (zero is fine).
  76. } MyVoiceInfo, *MyVoiceInfoPtr, **MyVoiceInfoH;
  77.  
  78.     
  79. typedef struct {
  80.     PPCParamBlockRec    pb;
  81.     PPCPortRec            portName;
  82.     LocationNameRec        locationName;
  83.     Str255                userName;
  84.     char                buffer[512];
  85. } SessionRecord, *SessionPtr;
  86.  
  87.  
  88. #define kSpeakString    1000 // use PPC toolbox to send a MyVoiceInfo record to daemon
  89. #define kNotifString    8888 // use PPC toolbox to send a Str255 to daemon to show notification box
  90. #define kShutUp            1005 // use PPC toolbox to pass unsigned long containing ticks value for the 
  91.                             // MyVoiceInfo record you want to shut up
  92.  
  93. #define DAEMON_NAME        "\pSpeech Daemon (PPC)"
  94. #define TEST_STRING        "\pWatson, come here. I need you."
  95.  
  96. #define CREATOR            'IF 8' // I went to International Falls Senior High & my    
  97.                                 // football jersey # was 8 (ok, I was the statistician,
  98.                                 // but I still wore a jersey)
  99. /* HandleTest will speak a string using the parameters passed to it in the 
  100. ** record vInfo points to. */
  101.  
  102. void HandleTest( MyVoiceInfoPtr    vInfo)
  103. {
  104.     OSErr                iErr;
  105.     short                refNum;
  106.     Str255                aString;
  107.     SessionRecord        sessionRecord;
  108.     iErr = OpenAPort(&refNum);
  109.     if(iErr)
  110.     {
  111.         SysBeep(8);
  112.     }
  113.     else
  114.     {
  115.         BlockMove(TEST_STRING, &vInfo->string2Speak, sizeof(TEST_STRING));
  116.         
  117.         
  118.         sessionRecord.portName.nameScript = smRoman;
  119.         BlockMove( DAEMON_NAME, sessionRecord.portName.name, sizeof( DAEMON_NAME));
  120.         
  121.         sessionRecord.portName.portKindSelector = ppcByCreatorAndType;
  122.         sessionRecord.portName.u.port.creator = CREATOR;
  123.         sessionRecord.portName.u.port.type = 'APPL';
  124.     
  125.         sessionRecord.pb.startParam.ioCompletion    = 0L;
  126.         sessionRecord.pb.startParam.portRefNum        = refNum;
  127.         sessionRecord.pb.startParam.serviceType        = ppcServiceRealTime;
  128.         sessionRecord.pb.startParam.resFlag            = 0;
  129.         sessionRecord.pb.startParam.portName        = &sessionRecord.portName;
  130.         sessionRecord.pb.startParam.locationName    = nil;
  131.         sessionRecord.pb.startParam.userData        = kSpeakString;
  132.         sessionRecord.pb.startParam.userRefNum        = 0;    /* guest access? */
  133.     
  134.         iErr = PPCStart(&sessionRecord.pb.startParam,FALSE);
  135.     
  136.     
  137.         if (iErr == noErr)
  138.         {
  139.             sessionRecord.pb.writeParam.ioCompletion    = 0L;
  140.             sessionRecord.pb.writeParam.bufferLength    = sizeof (MyVoiceInfo);
  141.             sessionRecord.pb.writeParam.bufferPtr        = (Ptr) vInfo;
  142.             sessionRecord.pb.writeParam.more            = false;
  143.             iErr = PPCWrite(&sessionRecord.pb.writeParam,FALSE);
  144.         }
  145.         else
  146.         {
  147.             SysBeep(8);
  148.         }
  149.  
  150.         iErr = PPCEnd(&sessionRecord.pb.endParam, false); // make sure transfer is done
  151.         iErr = PPCClose(&sessionRecord.pb.closeParam, false); // close open port
  152.     }
  153. }
  154. #define CODE_TYPE        'APPL' // put in your programs type 
  155. #define CODE_CREATOR    '????' // put in your creator type
  156. #define CODE_NAME        "\pUntitled Port"
  157. OSErr OpenAPort(short *refNum)
  158. {
  159.     PPCPortRec        thePort;
  160.     PPCOpenPBRec    pb;
  161.     OSErr            err;
  162.     Str255            portName;
  163.     
  164.     thePort.nameScript = smRoman;
  165.     BlockMove(CODE_NAME, thePort.name, sizeof(CODE_NAME));
  166.     thePort.portKindSelector = ppcByCreatorAndType;
  167.     thePort.u.port.creator = CODE_CREATOR;
  168.     thePort.u.port.type = CODE_TYPE;
  169.  
  170.     pb.ioCompletion = nil;
  171.     pb.serviceType = ppcServiceRealTime;
  172.     pb.resFlag = 0;
  173.     pb.networkVisible = false;
  174.     pb.portName = &thePort;
  175.     pb.locationName = nil;            // use the default location
  176.  
  177.     err = PPCOpen(&pb, false);
  178.     if (err) return(err);
  179.  
  180.     *refNum = pb.portRefNum;
  181.     return(noErr);
  182. }
  183.